Micron Document
<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Viterbi algorithm</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Viterbi_algorithm"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/ext.math.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Viterbi_algorithm rootpage-Viterbi_algorithm skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Viterbi algorithm</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<style data-mw-deduplicate="TemplateStyles:r1251242444">
/* start https://en.wikipedia.org/ */


.mw-parser-output .ambox{border:1px solid #a2a9b1;border-left:10px solid #36c;background-color:#fbfbfb;box-sizing:border-box}.mw-parser-output .ambox+link+.ambox,.mw-parser-output .ambox+link+style+.ambox,.mw-parser-output .ambox+link+link+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+style+.ambox,.mw-parser-output .ambox+.mw-empty-elt+link+link+.ambox{margin-top:-1px}html body.mediawiki .mw-parser-output .ambox.mbox-small-left{margin:4px 1em 4px 0;overflow:hidden;width:238px;border-collapse:collapse;font-size:88%;line-height:1.25em}.mw-parser-output .ambox-speedy{border-left:10px solid #b32424;background-color:#fee7e6}.mw-parser-output .ambox-delete{border-left:10px solid #b32424}.mw-parser-output .ambox-content{border-left:10px solid #f28500}.mw-parser-output .ambox-style{border-left:10px solid #fc3}.mw-parser-output .ambox-move{border-left:10px solid #9932cc}.mw-parser-output .ambox-protection{border-left:10px solid #a2a9b1}.mw-parser-output .ambox .mbox-text{border:none;padding:0.25em 0.5em;width:100%}.mw-parser-output .ambox .mbox-image{border:none;padding:2px 0 2px 0.5em;text-align:center}.mw-parser-output .ambox .mbox-imageright{border:none;padding:2px 0.5em 2px 0;text-align:center}.mw-parser-output .ambox .mbox-empty-cell{border:none;padding:0;width:1px}.mw-parser-output .ambox .mbox-image-div{width:52px}@media(min-width:720px){.mw-parser-output .ambox{margin:0 10%}}@media print{body.ns-0 .mw-parser-output .ambox{display:none!important}}


/* end https://en.wikipedia.org/ */
</style>
<p>The <b>Viterbi algorithm</b> is a <a href="Dynamic_programming" title="Dynamic programming">dynamic programming</a> <a href="Algorithm" title="Algorithm">algorithm</a> that finds the most likely sequence of hidden events that would explain a sequence of observed events. The result of the algorithm is often called the <b>Viterbi path</b>. It is most commonly used with <a href="Hidden_Markov_model" title="Hidden Markov model">hidden Markov models</a> (HMMs). For example, if a doctor observes a patient's symptoms over several days (the observed events), the Viterbi algorithm could determine the most probable sequence of underlying health conditions (the hidden events) that caused those symptoms.
</p><p>The algorithm has found universal application in decoding the <a href="Convolutional_code" title="Convolutional code">convolutional codes</a> used in both <a href="Code-division_multiple_access" title="Code-division multiple access">CDMA</a> and <a href="GSM" title="GSM">GSM</a> digital cellular, <a href="Dial-up_Internet_access" title="Dial-up Internet access">dial-up</a> modems, satellite, deep-space communications, and <a href="802.11" class="mw-redirect" title="802.11">802.11</a> wireless LANs. It is also commonly used in <a href="Speech_recognition" title="Speech recognition">speech recognition</a>, <a href="Speech_synthesis" title="Speech synthesis">speech synthesis</a>, <a href="Speaker_diarisation" title="Speaker diarisation">diarization</a>,<sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup> <a href="Keyword_spotting" title="Keyword spotting">keyword spotting</a>, <a href="Computational_linguistics" title="Computational linguistics">computational linguistics</a>, and <a href="Bioinformatics" title="Bioinformatics">bioinformatics</a>. For instance, in <a href="Speech-to-text" class="mw-redirect" title="Speech-to-text">speech-to-text</a> (speech recognition), the acoustic signal is the observed sequence, and a string of text is the "hidden cause" of that signal. The Viterbi algorithm finds the most likely string of text given the acoustic signal.
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="History">History</h2></div>
<p>The Viterbi algorithm is named after <a href="Andrew_Viterbi" title="Andrew Viterbi">Andrew Viterbi</a>, who proposed it in 1967 as a decoding algorithm for <a href="Convolution_code" class="mw-redirect" title="Convolution code">convolutional codes</a> over noisy digital communication links.<sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> It has, however, a history of <a href="Multiple_invention" class="mw-redirect" title="Multiple invention">multiple invention</a>, with at least seven independent discoveries, including those by Viterbi, <a href="Needleman%E2%80%93Wunsch_algorithm" title="Needleman–Wunsch algorithm">Needleman and Wunsch</a>, and <a href="Wagner%E2%80%93Fischer_algorithm" title="Wagner–Fischer algorithm">Wagner and Fischer</a>.<sup id="cite_ref-slp_3-0" class="reference"><a href="#cite_note-slp-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup> It was introduced to <a href="Natural_language_processing" title="Natural language processing">natural language processing</a> as a method of <a href="Part-of-speech_tagging" title="Part-of-speech tagging">part-of-speech tagging</a> as early as 1987.
</p><p><i>Viterbi path</i> and <i>Viterbi algorithm</i> have become standard terms for the application of dynamic programming algorithms to maximization problems involving probabilities.<sup id="cite_ref-slp_3-1" class="reference"><a href="#cite_note-slp-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup>
For example, in statistical parsing a dynamic programming algorithm can be used to discover the single most likely context-free derivation (parse) of a string, which is commonly called the "Viterbi parse".<sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-5" class="reference"><a href="#cite_note-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-6" class="reference"><a href="#cite_note-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup> Another application is in <a href="Optical_motion_tracking" class="mw-redirect" title="Optical motion tracking">target tracking</a>, where the track is computed that assigns a maximum likelihood to a sequence of observations.<sup id="cite_ref-7" class="reference"><a href="#cite_note-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="Algorithm">Algorithm</h2></div>
<p>Given a hidden Markov model with a set of hidden states <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle S}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>S</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle S}</annotation>
</semantics>
</math></span><img src="./4611d85173cd3b508e67077d4a1252c9c05abca2.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.499ex; height:2.176ex;" alt="{\displaystyle S}" loading="lazy"></span> and a sequence of <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle T}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>T</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle T}</annotation>
</semantics>
</math></span><img src="./ec7200acd984a1d3a3d7dc455e262fbe54f7f6e0.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.636ex; height:2.176ex;" alt="{\displaystyle T}" loading="lazy"></span> observations <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle o_{0},o_{1},\dots ,o_{T-1}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>o</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
</mrow>
</msub>
<mo>,</mo>
<msub>
<mi>o</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>1</mn>
</mrow>
</msub>
<mo>,</mo>
<mo>…<!-- … --></mo>
<mo>,</mo>
<msub>
<mi>o</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>T</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle o_{0},o_{1},\dots ,o_{T-1}}</annotation>
</semantics>
</math></span><img src="./961b37470ba672ddf5c8f0aa86bf23d80ca1fb63.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:15.193ex; height:2.009ex;" alt="{\displaystyle o_{0},o_{1},\dots ,o_{T-1}}" loading="lazy"></span>, the Viterbi algorithm finds the most likely sequence of states that could have produced those observations. At each time step <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle t}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>t</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle t}</annotation>
</semantics>
</math></span><img src="./65658b7b223af9e1acc877d848888ecdb4466560.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:0.84ex; height:2.009ex;" alt="{\displaystyle t}" loading="lazy"></span>, the algorithm solves the subproblem where only the observations up to <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle o_{t}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>o</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>t</mi>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle o_{t}}</annotation>
</semantics>
</math></span><img src="./3cd2cf4bfdabc8ae396ce3fa32aeb871efb3d732.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:1.954ex; height:2.009ex;" alt="{\displaystyle o_{t}}" loading="lazy"></span> are considered.
</p><p>Two matrices of size <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle T\times \left|{S}\right|}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>T</mi>
<mo>×<!-- × --></mo>
<mrow>
<mo>|</mo>
<mrow class="MJX-TeXAtom-ORD">
<mi>S</mi>
</mrow>
<mo>|</mo>
</mrow>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle T\times \left|{S}\right|}</annotation>
</semantics>
</math></span><img src="./503991e6d34c90301bfef089b6f8da94d8c27a46.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:7.27ex; height:2.843ex;" alt="{\displaystyle T\times \left|{S}\right|}" loading="lazy"></span> are constructed:
</p>
<ul><li><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle P_{t,s}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>P</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>t</mi>
<mo>,</mo>
<mi>s</mi>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle P_{t,s}}</annotation>
</semantics>
</math></span><img src="./2b67552369ac17012355486c518c9f0b86e7363f.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:3.547ex; height:2.843ex;" alt="{\displaystyle P_{t,s}}" loading="lazy"></span> contains the maximum probability of ending up at state <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle s}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>s</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle s}</annotation>
</semantics>
</math></span><img src="./01d131dfd7673938b947072a13a9744fe997e632.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.09ex; height:1.676ex;" alt="{\displaystyle s}" loading="lazy"></span> at observation <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle t}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>t</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle t}</annotation>
</semantics>
</math></span><img src="./65658b7b223af9e1acc877d848888ecdb4466560.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:0.84ex; height:2.009ex;" alt="{\displaystyle t}" loading="lazy"></span>, out of all possible sequences of states leading up to it.</li>
<li><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle Q_{t,s}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>Q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>t</mi>
<mo>,</mo>
<mi>s</mi>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle Q_{t,s}}</annotation>
</semantics>
</math></span><img src="./0b085c88019ace6bdd2de0aee09184a2f6947915.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:3.893ex; height:2.843ex;" alt="{\displaystyle Q_{t,s}}" loading="lazy"></span> tracks the previous state that was used before <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle s}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>s</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle s}</annotation>
</semantics>
</math></span><img src="./01d131dfd7673938b947072a13a9744fe997e632.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.09ex; height:1.676ex;" alt="{\displaystyle s}" loading="lazy"></span> in this maximum probability state sequence.</li></ul>
<p>Let <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \pi _{s}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>π<!-- π --></mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>s</mi>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \pi _{s}}</annotation>
</semantics>
</math></span><img src="./0dcfaac8814f5e62e87bca6bec267ee6e80808db.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:2.328ex; height:2.009ex;" alt="{\displaystyle \pi _{s}}" loading="lazy"></span> and <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle a_{r,s}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>a</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>r</mi>
<mo>,</mo>
<mi>s</mi>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle a_{r,s}}</annotation>
</semantics>
</math></span><img src="./6ff41ed98ee1c232f113fb3e4197d97427ea3353.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:3.432ex; height:2.343ex;" alt="{\displaystyle a_{r,s}}" loading="lazy"></span> be the initial and transition probabilities respectively, and let <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle b_{s,o}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>b</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>s</mi>
<mo>,</mo>
<mi>o</mi>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle b_{s,o}}</annotation>
</semantics>
</math></span><img src="./686dbe0a1403110992794769ba62210b169d6371.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:3.256ex; height:2.843ex;" alt="{\displaystyle b_{s,o}}" loading="lazy"></span> be the probability of observing <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle o}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>o</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle o}</annotation>
</semantics>
</math></span><img src="./0c1031f61947aa3d1cf3a70ec3e4904df2c3675d.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.128ex; height:1.676ex;" alt="{\displaystyle o}" loading="lazy"></span> at state <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle s}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>s</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle s}</annotation>
</semantics>
</math></span><img src="./01d131dfd7673938b947072a13a9744fe997e632.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.09ex; height:1.676ex;" alt="{\displaystyle s}" loading="lazy"></span>. Then the values of <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle P}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>P</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle P}</annotation>
</semantics>
</math></span><img src="./b4dc73bf40314945ff376bd363916a738548d40a.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.745ex; height:2.176ex;" alt="{\displaystyle P}" loading="lazy"></span> are given by the recurrence relation<sup id="cite_ref-8" class="reference"><a href="#cite_note-8"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup>
<span class="mwe-math-element mwe-math-element-block"><span class="mwe-math-mathml-display mwe-math-mathml-a11y" style="display: none;"><math display="block" xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle P_{t,s}={\begin{cases}\pi _{s}\cdot b_{s,o_{t}}&amp;{\text{if }}t=0,\\\max _{r\in S}\left(P_{t-1,r}\cdot a_{r,s}\cdot b_{s,o_{t}}\right)&amp;{\text{if }}t>0.\end{cases}}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>P</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>t</mi>
<mo>,</mo>
<mi>s</mi>
</mrow>
</msub>
<mo>=</mo>
<mrow class="MJX-TeXAtom-ORD">
<mrow>
<mo>{</mo>
<mtable columnalign="left left" rowspacing=".2em" columnspacing="1em" displaystyle="false">
<mtr>
<mtd>
<msub>
<mi>π<!-- π --></mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>s</mi>
</mrow>
</msub>
<mo>⋅<!-- ⋅ --></mo>
<msub>
<mi>b</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>s</mi>
<mo>,</mo>
<msub>
<mi>o</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>t</mi>
</mrow>
</msub>
</mrow>
</msub>
</mtd>
<mtd>
<mrow class="MJX-TeXAtom-ORD">
<mtext>if&nbsp;</mtext>
</mrow>
<mi>t</mi>
<mo>=</mo>
<mn>0</mn>
<mo>,</mo>
</mtd>
</mtr>
<mtr>
<mtd>
<munder>
<mo movablelimits="true" form="prefix">max</mo>
<mrow class="MJX-TeXAtom-ORD">
<mi>r</mi>
<mo>∈<!-- ∈ --></mo>
<mi>S</mi>
</mrow>
</munder>
<mrow>
<mo>(</mo>
<mrow>
<msub>
<mi>P</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>t</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
<mo>,</mo>
<mi>r</mi>
</mrow>
</msub>
<mo>⋅<!-- ⋅ --></mo>
<msub>
<mi>a</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>r</mi>
<mo>,</mo>
<mi>s</mi>
</mrow>
</msub>
<mo>⋅<!-- ⋅ --></mo>
<msub>
<mi>b</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>s</mi>
<mo>,</mo>
<msub>
<mi>o</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>t</mi>
</mrow>
</msub>
</mrow>
</msub>
</mrow>
<mo>)</mo>
</mrow>
</mtd>
<mtd>
<mrow class="MJX-TeXAtom-ORD">
<mtext>if&nbsp;</mtext>
</mrow>
<mi>t</mi>
<mo>&gt;</mo>
<mn>0.</mn>
</mtd>
</mtr>
</mtable>
<mo fence="true" stretchy="true" symmetric="true"></mo>
</mrow>
</mrow>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle P_{t,s}={\begin{cases}\pi _{s}\cdot b_{s,o_{t}}&amp;{\text{if }}t=0,\\\max _{r\in S}\left(P_{t-1,r}\cdot a_{r,s}\cdot b_{s,o_{t}}\right)&amp;{\text{if }}t&gt;0.\end{cases}}}</annotation>
</semantics>
</math></span></span>
The formula for <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle Q_{t,s}}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>Q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>t</mi>
<mo>,</mo>
<mi>s</mi>
</mrow>
</msub>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle Q_{t,s}}</annotation>
</semantics>
</math></span><img src="./0b085c88019ace6bdd2de0aee09184a2f6947915.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:3.893ex; height:2.843ex;" alt="{\displaystyle Q_{t,s}}" loading="lazy"></span> is identical for <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle t>0}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>t</mi>
<mo>&gt;</mo>
<mn>0</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle t&gt;0}</annotation>
</semantics>
</math></span><img src="./29a2960e88369263fe3cfe00ccbfeb83daee212a.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:5.101ex; height:2.176ex;" alt="{\displaystyle t>0}" loading="lazy"></span>, except that <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \max }">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mo movablelimits="true" form="prefix">max</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \max }</annotation>
</semantics>
</math></span><img src="./b8e49fca3e322708b32d21eaa8b095dc05f09538.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:4.326ex; height:1.676ex;" alt="{\displaystyle \max }" loading="lazy"></span> is replaced with <a href="Arg_max" title="Arg max"><span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle \arg \max }">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>arg</mi>
<mo>⁡<!-- ⁡ --></mo>
<mo movablelimits="true" form="prefix">max</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle \arg \max }</annotation>
</semantics>
</math></span><img src="./6d5b88799aa6426718d91e6749b77cd6195653e5.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:7.949ex; height:2.009ex;" alt="{\displaystyle \arg \max }" loading="lazy"></span></a>, and <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle Q_{0,s}=0}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<msub>
<mi>Q</mi>
<mrow class="MJX-TeXAtom-ORD">
<mn>0</mn>
<mo>,</mo>
<mi>s</mi>
</mrow>
</msub>
<mo>=</mo>
<mn>0</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle Q_{0,s}=0}</annotation>
</semantics>
</math></span><img src="./789748cf1c372bd88ea0f2fe63715ef815965c06.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -1.005ex; width:8.382ex; height:2.843ex;" alt="{\displaystyle Q_{0,s}=0}" loading="lazy"></span>.
The Viterbi path can be found by selecting the maximum of <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle P}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>P</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle P}</annotation>
</semantics>
</math></span><img src="./b4dc73bf40314945ff376bd363916a738548d40a.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.745ex; height:2.176ex;" alt="{\displaystyle P}" loading="lazy"></span> at the final timestep, and following <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle Q}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>Q</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle Q}</annotation>
</semantics>
</math></span><img src="./8752c7023b4b3286800fe3238271bbca681219ed.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.671ex; width:1.838ex; height:2.509ex;" alt="{\displaystyle Q}" loading="lazy"></span> in reverse.
</p>
<div class="mw-heading mw-heading2"><h2 id="Pseudocode">Pseudocode</h2></div>
<pre><b>function</b> Viterbi(states, init, trans, emit, obs) <b>is</b>
<b>input</b> states: S hidden states
<b>input</b> init: initial probabilities of each state
<b>input</b> trans: S × S transition matrix
<b>input</b> emit: S × O emission matrix
<b>input</b> obs: sequence of T observations

prob ← T × S matrix of zeroes
prev ← empty T × S matrix
<b>for</b> <b>each</b> state s <b>in</b> states <b>do</b>
prob[0][s] = init[s] * emit[s][obs[0]]

<b>for</b> t = 1 <b>to</b> T - 1 <b>inclusive do</b> <i>// t = 0 has been dealt with already</i>
<b>for</b> <b>each</b> state s <b>in</b> states <b>do</b>
<b>for</b> <b>each</b> state r <b>in</b> states <b>do</b>
new_prob ← prob[t - 1][r] * trans[r][s] * emit[s][obs[t]]
<b>if</b> new_prob &gt; prob[t][s] <b>then</b>
prob[t][s] ← new_prob
prev[t][s] ← r

path ← empty array of length T
path[T - 1] ← the state s with maximum prob[T - 1][s]
<b>for</b> t = T - 2 <b>to</b> 0 <b>inclusive do</b>
path[t] ← prev[t + 1][path[t + 1]]

<b>return</b> path
<b>end</b>
</pre>
<p>The time complexity of the algorithm is <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle O(T\times \left|{S}\right|^{2})}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>O</mi>
<mo stretchy="false">(</mo>
<mi>T</mi>
<mo>×<!-- × --></mo>
<msup>
<mrow>
<mo>|</mo>
<mrow class="MJX-TeXAtom-ORD">
<mi>S</mi>
</mrow>
<mo>|</mo>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mn>2</mn>
</mrow>
</msup>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle O(T\times \left|{S}\right|^{2})}</annotation>
</semantics>
</math></span><img src="./beee12098b9ff184ac5fb053dc61eb322eea6b2f.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:11.906ex; height:3.343ex;" alt="{\displaystyle O(T\times \left|{S}\right|^{2})}" loading="lazy"></span>. If it is known which state transitions have non-zero probability, an improved bound can be found by iterating over only those <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle r}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>r</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle r}</annotation>
</semantics>
</math></span><img src="./0d1ecb613aa2984f0576f70f86650b7c2a132538.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.049ex; height:1.676ex;" alt="{\displaystyle r}" loading="lazy"></span> which link to <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle s}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>s</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle s}</annotation>
</semantics>
</math></span><img src="./01d131dfd7673938b947072a13a9744fe997e632.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.09ex; height:1.676ex;" alt="{\displaystyle s}" loading="lazy"></span> in the inner loop. Then using <a href="Amortized_analysis" title="Amortized analysis">amortized analysis</a> one can show that the complexity is <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle O(T\times (\left|{S}\right|+\left|{E}\right|))}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>O</mi>
<mo stretchy="false">(</mo>
<mi>T</mi>
<mo>×<!-- × --></mo>
<mo stretchy="false">(</mo>
<mrow>
<mo>|</mo>
<mrow class="MJX-TeXAtom-ORD">
<mi>S</mi>
</mrow>
<mo>|</mo>
</mrow>
<mo>+</mo>
<mrow>
<mo>|</mo>
<mrow class="MJX-TeXAtom-ORD">
<mi>E</mi>
</mrow>
<mo>|</mo>
</mrow>
<mo stretchy="false">)</mo>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle O(T\times (\left|{S}\right|+\left|{E}\right|))}</annotation>
</semantics>
</math></span><img src="./3498e4e3a96ef7e9d657f31c3f7bf88aa39bec93.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:18.571ex; height:2.843ex;" alt="{\displaystyle O(T\times (\left|{S}\right|+\left|{E}\right|))}" loading="lazy"></span>, where <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle E}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>E</mi>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle E}</annotation>
</semantics>
</math></span><img src="./4232c9de2ee3eec0a9c0a19b15ab92daa6223f9b.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:1.776ex; height:2.176ex;" alt="{\displaystyle E}" loading="lazy"></span> is the number of edges in the graph, i.e. the number of non-zero entries in the transition matrix.
</p>
<div class="mw-heading mw-heading2"><h2 id="Example">Example</h2></div>
<p>A doctor wishes to determine whether patients are healthy or have a fever. The only information the doctor can obtain is by asking patients how they feel. The patients may report that they either feel normal, dizzy, or cold.
</p><p>It is believed that the health condition of the patients operates as a discrete <a href="Markov_chain" title="Markov chain">Markov chain</a>. There are two states, "healthy" and "fever", but the doctor cannot observe them directly; they are <i>hidden</i> from the doctor. On each day, the chance that a patient tells the doctor "I feel normal", "I feel cold", or "I feel dizzy", depends only on the patient's health condition on that day.
</p><p>The <i>observations</i> (normal, cold, dizzy) along with the <i>hidden</i> states (healthy, fever) form a hidden Markov model (HMM). From past experience, the probabilities of this model have been estimated as:
</p>
<pre>init = {"Healthy": 0.6, "Fever": 0.4}
trans = {
"Healthy": {"Healthy": 0.7, "Fever": 0.3},
"Fever": {"Healthy": 0.4, "Fever": 0.6},
}
emit = {
"Healthy": {"normal": 0.5, "cold": 0.4, "dizzy": 0.1},
"Fever": {"normal": 0.1, "cold": 0.3, "dizzy": 0.6},
}
</pre>
<p>In this code, <code>init</code> represents the doctor's belief about how likely the patient is to be healthy initially. Note that the particular probability distribution used here is not the equilibrium one, which would be <code>{'Healthy': 0.57, 'Fever': 0.43}</code> according to the transition probabilities. The transition probabilities <code>trans</code> represent the change of health condition in the underlying Markov chain. In this example, a patient who is healthy today has only a 30% chance of having a fever tomorrow. The emission probabilities <code>emit</code> represent how likely each possible observation (normal, cold, or dizzy) is, given the underlying condition (healthy or fever). A patient who is healthy has a 50% chance of feeling normal; one who has a fever has a 60% chance of feeling dizzy.
</p>

<p>A particular patient visits three days in a row, and reports feeling normal on the first day, cold on the second day, and dizzy on the third day.
</p><p>Firstly, the probabilities of being healthy or having a fever on the first day are calculated. The probability that a patient will be healthy on the first day and report feeling normal is <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 0.6\times 0.5=0.3}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mn>0.6</mn>
<mo>×<!-- × --></mo>
<mn>0.5</mn>
<mo>=</mo>
<mn>0.3</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle 0.6\times 0.5=0.3}</annotation>
</semantics>
</math></span><img src="./229360aa5c3fa650b28fb1e7930f0e555fbd1fd7.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:14.854ex; height:2.176ex;" alt="{\displaystyle 0.6\times 0.5=0.3}" loading="lazy"></span>. Similarly, the probability that a patient will have a fever on the first day and report feeling normal is <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 0.4\times 0.1=0.04}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mn>0.4</mn>
<mo>×<!-- × --></mo>
<mn>0.1</mn>
<mo>=</mo>
<mn>0.04</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle 0.4\times 0.1=0.04}</annotation>
</semantics>
</math></span><img src="./1cf03d25171f9c6167d26ecd0a9ac8d1ca1ccc87.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:16.017ex; height:2.176ex;" alt="{\displaystyle 0.4\times 0.1=0.04}" loading="lazy"></span>.
</p><p>The probabilities for each of the following days can be calculated from the previous day directly. For example, the highest chance of being healthy on the second day and reporting to be cold, following reporting being normal on the first day, is the maximum of <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 0.3\times 0.7\times 0.4=0.084}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mn>0.3</mn>
<mo>×<!-- × --></mo>
<mn>0.7</mn>
<mo>×<!-- × --></mo>
<mn>0.4</mn>
<mo>=</mo>
<mn>0.084</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle 0.3\times 0.7\times 0.4=0.084}</annotation>
</semantics>
</math></span><img src="./1e24d5c7cef810af6ee7c3a1a53d0d9bbfb67a58.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:22.991ex; height:2.176ex;" alt="{\displaystyle 0.3\times 0.7\times 0.4=0.084}" loading="lazy"></span> and <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle 0.04\times 0.4\times 0.4=0.0064}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mn>0.04</mn>
<mo>×<!-- × --></mo>
<mn>0.4</mn>
<mo>×<!-- × --></mo>
<mn>0.4</mn>
<mo>=</mo>
<mn>0.0064</mn>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle 0.04\times 0.4\times 0.4=0.0064}</annotation>
</semantics>
</math></span><img src="./10900181b94e3acdc027a435fd6bbe9058bd224c.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.338ex; width:25.316ex; height:2.176ex;" alt="{\displaystyle 0.04\times 0.4\times 0.4=0.0064}" loading="lazy"></span>. This suggests it is more likely that the patient was healthy for both of those days, rather than having a fever and recovering.
</p><p>The rest of the probabilities are summarised in the following table:
</p>
<table class="wikitable">

<tbody><tr>
<th>Day</th>
<th>1</th>
<th>2</th>
<th>3
</th></tr>
<tr>
<th>Observation
</th>
<td>Normal</td>
<td>Cold</td>
<td>Dizzy
</td></tr>
<tr>
<th>Healthy
</th>
<td><b>0.3</b></td>
<td><b>0.084</b></td>
<td>0.00588
</td></tr>
<tr>
<th>Fever
</th>
<td>0.04</td>
<td>0.027</td>
<td><b>0.01512</b>
</td></tr></tbody></table>
<p>From the table, it can be seen that the patient most likely had a fever on the third day. Furthermore, there exists a sequence of states ending on "fever", of which the probability of producing the given observations is 0.01512. This sequence is precisely (healthy, healthy, fever), which can be found be tracing back which states were used when calculating the maxima (which happens to be the best guess from each day but will not always be). In other words, given the observed activities, the patient was most likely to have been healthy on the first day and also on the second day (despite feeling cold that day), and only to have contracted a fever on the third day.
</p><p>The operation of Viterbi's algorithm can be visualized by means of a <a href="Trellis_diagram" class="mw-redirect" title="Trellis diagram">trellis diagram</a>. The Viterbi path is essentially the shortest path through this trellis.
</p>
<div class="mw-heading mw-heading2"><h2 id="Extensions">Extensions</h2></div>
<p>A generalization of the Viterbi algorithm, termed the <i>max-sum algorithm</i> (or <i>max-product algorithm</i>) can be used to find the most likely assignment of all or some subset of <a href="Latent_variable" class="mw-redirect" title="Latent variable">latent variables</a> in a large number of <a href="Graphical_model" title="Graphical model">graphical models</a>, e.g. <a href="Bayesian_network" title="Bayesian network">Bayesian networks</a>, <a href="Markov_random_field" title="Markov random field">Markov random fields</a> and <a href="Conditional_random_field" title="Conditional random field">conditional random fields</a>. The latent variables need, in general, to be connected in a way somewhat similar to a <a href="Hidden_Markov_model" title="Hidden Markov model">hidden Markov model</a> (HMM), with a limited number of connections between variables and some type of linear structure among the variables. The general algorithm involves <i>message passing</i> and is substantially similar to the <a href="Belief_propagation" title="Belief propagation">belief propagation</a> algorithm (which is the generalization of the <a href="Forward-backward_algorithm" class="mw-redirect" title="Forward-backward algorithm">forward-backward algorithm</a>).
</p><p>With an algorithm called <a href="Iterative_Viterbi_decoding" title="Iterative Viterbi decoding">iterative Viterbi decoding</a>, one can find the subsequence of an observation that matches best (on average) to a given hidden Markov model. This algorithm is proposed by Qi Wang et al. to deal with <a href="Turbo_code" title="Turbo code">turbo code</a>.<sup id="cite_ref-9" class="reference"><a href="#cite_note-9"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup> Iterative Viterbi decoding works by iteratively invoking a modified Viterbi algorithm, reestimating the score for a filler until convergence.
</p><p>An alternative algorithm, the Lazy Viterbi algorithm, has been proposed.<sup id="cite_ref-10" class="reference"><a href="#cite_note-10"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup> For many applications of practical interest, under reasonable noise conditions, the lazy decoder (using Lazy Viterbi algorithm) is much faster than the original <a href="Viterbi_decoder" title="Viterbi decoder">Viterbi decoder</a> (using Viterbi algorithm). While the original Viterbi algorithm calculates every node in the <a href="Trellis_(graph)" title="Trellis (graph)">trellis</a> of possible outcomes, the Lazy Viterbi algorithm maintains a prioritized list of nodes to evaluate in order, and the number of calculations required is typically fewer (and never more) than the ordinary Viterbi algorithm for the same result. However, it is not so easy to parallelize in hardware.
</p>
<div class="mw-heading mw-heading2"><h2 id="Soft_output_Viterbi_algorithm">Soft output Viterbi algorithm</h2></div>

<p>The <b>soft output Viterbi algorithm</b> (<b>SOVA</b>) is a variant of the classical Viterbi algorithm.
</p><p>SOVA differs from the classical Viterbi algorithm in that it uses a modified path metric which takes into account the <a href="A_priori_probability" class="mw-redirect" title="A priori probability"><i>a priori probabilities</i></a> of the input symbols, and produces a <i>soft</i> output indicating the <i>reliability</i> of the decision.
</p><p>The first step in the SOVA is the selection of the survivor path, passing through one unique node at each time instant, <i>t</i>. Since each node has 2 branches converging at it (with one branch being chosen to form the <i>Survivor Path</i>, and the other being discarded), the difference in the branch metrics (or <i>cost</i>) between the chosen and discarded branches indicate the <i>amount of error</i> in the choice.
</p><p>This <i>cost</i> is accumulated over the entire sliding window (usually equals <i>at least</i> five constraint lengths), to indicate the <i>soft output</i> measure of reliability of the <i>hard bit decision</i> of the Viterbi algorithm.
</p>
<div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div>
<ul><li><a href="Expectation%E2%80%93maximization_algorithm" title="Expectation–maximization algorithm">Expectation–maximization algorithm</a></li>
<li><a href="Baum%E2%80%93Welch_algorithm" title="Baum–Welch algorithm">Baum–Welch algorithm</a></li>
<li><a href="Forward-backward_algorithm" class="mw-redirect" title="Forward-backward algorithm">Forward-backward algorithm</a></li>
<li><a href="Forward_algorithm" title="Forward algorithm">Forward algorithm</a></li>
<li><a href="Error-correcting_code" class="mw-redirect" title="Error-correcting code">Error-correcting code</a></li>
<li><a href="Viterbi_decoder" title="Viterbi decoder">Viterbi decoder</a></li>
<li><a href="Hidden_Markov_model" title="Hidden Markov model">Hidden Markov model</a></li>
<li><a href="Part-of-speech_tagging" title="Part-of-speech tagging">Part-of-speech tagging</a></li>
<li><a href="A*_search_algorithm" title="A* search algorithm">A* search algorithm</a></li></ul>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
/* start https://en.wikipedia.org/ */


.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}


/* end https://en.wikipedia.org/ */
</style><div class="reflist">
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-1">^</a></b></span> <span class="reference-text">Xavier Anguera et al., <a rel="nofollow" class="external text" href="http://www1.icsi.berkeley.edu/~vinyals/Files/taslp2011a.pdf">"Speaker Diarization: A Review of Recent Research"</a> <a rel="nofollow" class="external text" href="https://web.archive.org/web/20160512200056/http://www1.icsi.berkeley.edu/~vinyals/Files/taslp2011a.pdf">Archived</a> 2016-05-12 at the <a href="Wayback_Machine" title="Wayback Machine">Wayback Machine</a>, retrieved 19. August 2010, IEEE TASLP</span>
</li>
<li id="cite_note-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-2">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="https://arxiv.org/abs/cs/0504020v2">29 Apr 2005, G. David Forney Jr: The Viterbi Algorithm: A Personal History</a></span>
</li>
<li id="cite_note-slp-3"><span class="mw-cite-backlink">^ <a href="#cite_ref-slp_3-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-slp_3-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */


.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}


/* end https://en.wikipedia.org/ */
</style><cite id="CITEREFDaniel_JurafskyJames_H._Martin" class="citation book cs1">Daniel Jurafsky; James H. Martin. <i>Speech and Language Processing</i>. Pearson Education International. p.&nbsp;246.</cite></span>
</li>
<li id="cite_note-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-4">^</a></b></span> <span class="reference-text"><cite id="CITEREFSchmid2004" class="citation conference cs1">Schmid, Helmut (2004). <a rel="nofollow" class="external text" href="http://www.aclweb.org/anthology/C/C04/C04-1024.pdf"><i>Efficient parsing of highly ambiguous context-free grammars with bit vectors</i></a> <span class="cs1-format">(PDF)</span>. Proc. 20th Int'l Conf. on Computational Linguistics (COLING). <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.3115%2F1220355.1220379">10.3115/1220355.1220379</a></span>.</cite></span>
</li>
<li id="cite_note-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-5">^</a></b></span> <span class="reference-text"><cite id="CITEREFKleinManning2003" class="citation conference cs1">Klein, Dan; Manning, Christopher D. (2003). <a rel="nofollow" class="external text" href="http://ilpubs.stanford.edu:8090/532/1/2002-16.pdf"><i>A* parsing: fast exact Viterbi parse selection</i></a> <span class="cs1-format">(PDF)</span>. Proc. 2003 Conf. of the North American Chapter of the Association for Computational Linguistics on Human Language Technology (NAACL). pp.&nbsp;<span class="nowrap">40–</span>47. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://doi.org/10.3115%2F1073445.1073461">10.3115/1073445.1073461</a></span>.</cite></span>
</li>
<li id="cite_note-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-6">^</a></b></span> <span class="reference-text"><cite id="CITEREFStankeKellerGunduzHayes2006" class="citation journal cs1">Stanke, M.; Keller, O.; Gunduz, I.; Hayes, A.; Waack, S.; Morgenstern, B. (2006). <a rel="nofollow" class="external text" href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC1538822">"AUGUSTUS: Ab initio prediction of alternative transcripts"</a>. <i>Nucleic Acids Research</i>. <b>34</b> (Web Server issue): <span class="nowrap">W435 –</span> <span class="nowrap">W439</span>. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1093%2Fnar%2Fgkl200">10.1093/nar/gkl200</a>. <a href="PMC_(identifier)" class="mw-redirect" title="PMC (identifier)">PMC</a>&nbsp;<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC1538822">1538822</a></span>. <a href="PMID_(identifier)" class="mw-redirect" title="PMID (identifier)">PMID</a>&nbsp;<a rel="nofollow" class="external text" href="https://pubmed.ncbi.nlm.nih.gov/16845043">16845043</a>.</cite></span>
</li>
<li id="cite_note-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-7">^</a></b></span> <span class="reference-text"><cite id="CITEREFQuach,_T.;_Farooq,_M.1994" class="citation conference cs1">Quach, T.; Farooq, M. (1994). "Maximum Likelihood Track Formation with the Viterbi Algorithm". <i>Proceedings of 33rd IEEE Conference on Decision and Control</i>. Vol.&nbsp;1. pp.&nbsp;<span class="nowrap">271–</span>276. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1109%2FCDC.1994.410918">10.1109/CDC.1994.410918</a>.</cite><span class="cs1-maint citation-comment"><code class="cs1-code">{{cite conference}}</code>: CS1 maint: multiple names: authors list (link)</span></span>
</li>
<li id="cite_note-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-8">^</a></b></span> <span class="reference-text">Xing E, slide 11.</span>
</li>
<li id="cite_note-9"><span class="mw-cite-backlink"><b><a href="#cite_ref-9">^</a></b></span> <span class="reference-text"><cite id="CITEREFQi_WangLei_WeiRodney_A._Kennedy2002" class="citation journal cs1">Qi Wang; Lei Wei; Rodney A. Kennedy (2002). "Iterative Viterbi Decoding, Trellis Shaping, and Multilevel Structure for High-Rate Parity-Concatenated TCM". <i>IEEE Transactions on Communications</i>. <b>50</b>: <span class="nowrap">48–</span>55. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1109%2F26.975743">10.1109/26.975743</a>.</cite></span>
</li>
<li id="cite_note-10"><span class="mw-cite-backlink"><b><a href="#cite_ref-10">^</a></b></span> <span class="reference-text"><cite class="citation conference cs1"><a rel="nofollow" class="external text" href="http://people.csail.mit.edu/jonfeld/pubs/lazyviterbi.pdf"><i>A fast maximum-likelihood decoder for convolutional codes</i></a> <span class="cs1-format">(PDF)</span>. <a rel="nofollow" class="external text" href="http://www.ieeevtc.org/">Vehicular Technology Conference</a>. December 2002. pp.&nbsp;<span class="nowrap">371–</span>375. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1109%2FVETECF.2002.1040367">10.1109/VETECF.2002.1040367</a>.</cite></span>
</li>
</ol></div></div>
<div class="mw-heading mw-heading2"><h2 id="General_references">General references</h2></div>
<ul><li><cite id="CITEREFViterbi_AJ1967" class="citation journal cs1">Viterbi AJ (April 1967). "Error bounds for convolutional codes and an asymptotically optimum decoding algorithm". <i>IEEE Transactions on Information Theory</i>. <b>13</b> (2): <span class="nowrap">260–</span>269. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1109%2FTIT.1967.1054010">10.1109/TIT.1967.1054010</a>.</cite> (note: the Viterbi decoding algorithm is described in section IV.) Subscription required.</li>
<li><cite id="CITEREFFeldmanAbou-FaycalFrigo2002" class="citation book cs1">Feldman J, Abou-Faycal I, Frigo M (2002). "A fast maximum-likelihood decoder for convolutional codes". <i>Proceedings IEEE 56th Vehicular Technology Conference</i>. Vol.&nbsp;1. pp.&nbsp;<span class="nowrap">371–</span>375. <a href="CiteSeerX_(identifier)" class="mw-redirect" title="CiteSeerX (identifier)">CiteSeerX</a>&nbsp;<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.114.1314">10.1.1.114.1314</a></span>. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1109%2FVETECF.2002.1040367">10.1109/VETECF.2002.1040367</a>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>978-0-7803-7467-6</bdi>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a>&nbsp;<a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:9783963">9783963</a>.</cite></li>
<li><cite id="CITEREFForney_GD1973" class="citation journal cs1">Forney GD (March 1973). "The Viterbi algorithm". <i>Proceedings of the IEEE</i>. <b>61</b> (3): <span class="nowrap">268–</span>278. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1109%2FPROC.1973.9030">10.1109/PROC.1973.9030</a>.</cite> Subscription required.</li>
<li><cite id="CITEREFPressTeukolskyVetterlingFlannery2007" class="citation book cs1">Press, WH; Teukolsky, SA; Vetterling, WT; Flannery, BP (2007). <a rel="nofollow" class="external text" href="https://web.archive.org/web/20110811154417/http://apps.nrbook.com/empanel/index.html#pg=850">"Section 16.2. Viterbi Decoding"</a>. <i>Numerical Recipes: The Art of Scientific Computing</i> (3rd&nbsp;ed.). New York: Cambridge University Press. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>978-0-521-88068-8</bdi>. Archived from <a rel="nofollow" class="external text" href="http://apps.nrbook.com/empanel/index.html#pg=850">the original</a> on 2011-08-11<span class="reference-accessdate">. Retrieved <span class="nowrap">2011-08-17</span></span>.</cite></li>
<li><cite id="CITEREFRabiner_LR1989" class="citation journal cs1">Rabiner LR (February 1989). "A tutorial on hidden Markov models and selected applications in speech recognition". <i>Proceedings of the IEEE</i>. <b>77</b> (2): <span class="nowrap">257–</span>286. <a href="CiteSeerX_(identifier)" class="mw-redirect" title="CiteSeerX (identifier)">CiteSeerX</a>&nbsp;<span class="id-lock-free" title="Freely accessible"><a rel="nofollow" class="external text" href="https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.381.3454">10.1.1.381.3454</a></span>. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1109%2F5.18626">10.1109/5.18626</a>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a>&nbsp;<a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:13618539">13618539</a>.</cite> (Describes the forward algorithm and Viterbi algorithm for HMMs).</li>
<li>Shinghal, R. and <a href="Godfried_Toussaint" title="Godfried Toussaint">Godfried T. Toussaint</a>, "Experiments in text recognition with the modified Viterbi algorithm," <i>IEEE Transactions on Pattern Analysis and Machine Intelligence</i>, Vol. PAMI-l, April 1979, pp.&nbsp;184–193.</li>
<li>Shinghal, R. and <a href="Godfried_Toussaint" title="Godfried Toussaint">Godfried T. Toussaint</a>, "The sensitivity of the modified Viterbi algorithm to the source statistics," <i>IEEE Transactions on Pattern Analysis and Machine Intelligence</i>, vol. PAMI-2, March 1980, pp.&nbsp;181–185.</li></ul>
<div class="mw-heading mw-heading2"><h2 id="External_links">External links</h2></div>
<ul><li><a href="https://en.wikibooks.org/wiki/Algorithm_Implementation/Viterbi_algorithm" class="extiw external" title="b:Algorithm Implementation/Viterbi algorithm">Implementations in Java, F#, Clojure, C# on Wikibooks</a></li>
<li><a rel="nofollow" class="external text" href="http://pl91.ddns.net/viterbi/tutorial.html">Tutorial</a> on convolutional coding with viterbi decoding, by Chip Fleming</li>
<li><a rel="nofollow" class="external text" href="http://www.kanungo.com/software/hmmtut.pdf">A tutorial for a Hidden Markov Model toolkit (implemented in C) that contains a description of the Viterbi algorithm</a></li>
<li><a rel="nofollow" class="external text" href="http://www.scholarpedia.org/article/Viterbi_algorithm">Viterbi algorithm</a> by Dr. <a href="Andrew_Viterbi" title="Andrew Viterbi">Andrew J. Viterbi</a> (scholarpedia.org).</li></ul>
<div class="mw-heading mw-heading3"><h3 id="Implementations">Implementations</h3></div>
<ul><li><a rel="nofollow" class="external text" href="https://reference.wolfram.com/language/ref/FindHiddenMarkovStates.html">Mathematica</a> has an implementation as part of its support for stochastic processes</li>
<li><a rel="nofollow" class="external text" href="http://libsusa.org/">Susa</a> signal processing framework provides the C++ implementation for <a href="Forward_error_correction" class="mw-redirect" title="Forward error correction">Forward error correction</a> codes and channel equalization <a rel="nofollow" class="external text" href="https://github.com/libsusa/susa/blob/master/inc/susa/channel.h">here</a>.</li>
<li><a rel="nofollow" class="external text" href="https://github.com/xukmin/viterbi">C++</a></li>
<li><a rel="nofollow" class="external text" href="http://pcarvalho.com/forward_viterbi/">C#</a></li>
<li><a rel="nofollow" class="external text" href="http://www.cs.stonybrook.edu/~pfodor/viterbi/Viterbi.java">Java</a> <a rel="nofollow" class="external text" href="https://web.archive.org/web/20140504055101/http://www.cs.stonybrook.edu/~pfodor/viterbi/Viterbi.java">Archived</a> 2014-05-04 at the <a href="Wayback_Machine" title="Wayback Machine">Wayback Machine</a></li>
<li><a rel="nofollow" class="external text" href="https://adrianulbona.github.io/hmm/">Java 8</a></li>
<li><a rel="nofollow" class="external text" href="https://juliahub.com/ui/Packages/HMMBase/8HxY5/">Julia (HMMBase.jl)</a></li>
<li><a rel="nofollow" class="external text" href="https://metacpan.org/module/Algorithm::Viterbi">Perl</a></li>
<li><a rel="nofollow" class="external text" href="http://www.cs.stonybrook.edu/~pfodor/viterbi/viterbi.P">Prolog</a> <a rel="nofollow" class="external text" href="https://web.archive.org/web/20120502010115/http://www.cs.stonybrook.edu/~pfodor/viterbi/viterbi.P">Archived</a> 2012-05-02 at the <a href="Wayback_Machine" title="Wayback Machine">Wayback Machine</a></li>
<li><a rel="nofollow" class="external text" href="https://hackage.haskell.org/package/hmm-0.2.1.1/docs/src/Data-HMM.html#viterbi">Haskell</a></li>
<li><a rel="nofollow" class="external text" href="https://github.com/nyxtom/viterbi">Go</a></li>
<li><a rel="nofollow" class="external text" href="http://tuvalu.santafe.edu/~simon/styled-8/">SFIHMM</a> includes code for Viterbi decoding.</li></ul></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2025-07-27" href="https://en.wikipedia.org/wiki/?title=Viterbi_algorithm&amp;oldid=1302813257">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>

</body></html>